package my.jwds.p728;

import java.util.ArrayList;
import java.util.List;

public class SelfDividingNumbers {

    public static void main(String[] args) {

        SelfDividingNumbers obj = new SelfDividingNumbers();
        long start = System.currentTimeMillis();
        System.out.println(obj.selfDividingNumbers(10,22));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    public List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> res = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            int temp = i;
            boolean flag = true;
            while(temp != 0){
                int diff =(temp%10);
                if (diff == 0 || i % diff != 0){
                    flag = false;
                    break;
                }
                temp/=10;
            }
            if (flag)res.add(i);
        }
        return res;
    }
}